﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model;
using DAL;
using DBUlitity;
using System.Data;

namespace BLL
{
    public  class RoleInfoBLL
    {
        public static string initCustomerInfo(string CustomerName)
        {
            string jsonStr = "[]";
            List<CustomerInfo> customerList = RoleInfoDAL.initCustomerInfo(CustomerName);
            jsonStr = JSONTools.ScriptSerialize<List<CustomerInfo>>(customerList);
            return jsonStr;
        }
        /// <summary>
        /// 保存新增角色
        /// </summary>
        /// <param name="RoleName"></param>
        /// <param name="CustomName"></param>
        /// <param name="Remark"></param>
        /// <param name="quanxian"></param>
        /// <returns></returns>
        public static string addRoleInfo(string RoleName, string CustomName, string Remark, List<string> quanxian)
        {
            string jsonStr = RoleInfoDAL.addRoleInfo(RoleName,CustomName,Remark,quanxian);
            return jsonStr;
        }
        /// <summary>
        /// 保存编辑角色信息
        /// </summary>
        /// <param name="RoleName"></param>
        /// <param name="CustomName"></param>
        /// <param name="Remark"></param>
        /// <param name="quanxian"></param>
        /// <returns></returns>
        public static string editRoleInfo(string RoleID, string RoleName, string Remark, List<string> quanxian)
        {
            string jsonStr = RoleInfoDAL.editRoleInfo(RoleID,RoleName, Remark, quanxian);
            return jsonStr;
        }

        public static DataTable getRoleInfo(string sidx, string sord, string keyvalue, string CustomerName)
        {
            DataTable dt = new DataTable();
            dt = RoleInfoDAL.getRoleInfo(sidx, sord, keyvalue, CustomerName);
            return dt;
        }


        public static string getRoleInfoByID(string RoleID)
        {
            string jsonStr = "[]";
            List<RoleInfoWithLimit> customerList = RoleInfoDAL.getRoleInfoByID(RoleID);
            jsonStr = JSONTools.ScriptSerialize<List<RoleInfoWithLimit>>(customerList);
            return jsonStr;
        }
        public static string deleteRoleInfo(string RoleID)
        {
            int t = RoleInfoDAL.deleteRoleInfo(RoleID);
            string jsonStr = string.Empty;
            if (t > 0)
            {
                jsonStr = "success";
            }
            else
            {
                jsonStr = "flaut";
            }
            return jsonStr;
        }
    }
}
